<?php

function getConnection()
{
	$con = mysql_connect("localhost","root","wangwei");
	if (!$con) {
		die('Could not connect: ' . mysql_error());
	}
	mysql_query("SET NAMES 'utf8'", $con);
	mysql_select_db("xmtrain", $con);
	
	return $con;
}

function getMaxID($id, $table)
{	
	$result = mysql_query("select max(" . $id . ") maxid from " . $table);
	
	while($row = mysql_fetch_array($result))
	{
		$maxID =  $row['maxid'];
	}
	
	return $maxID;
}